package config

import (
	"errors"
	"flyinfo/actions"
	"fmt"
)

type action struct {
	Type string   `json:"type"`
	Args []string `json:"args"`
}

func (a *action) Execute() error {
	actionFunction, existAction := actions.Map[a.Type]
	if !existAction {
		return errors.New(fmt.Sprintf("no such action: %s", a.Type))
	}
	return actionFunction(a.Args)
}
